package com.cn.api.util;

import java.io.UnsupportedEncodingException;
import java.security.MessageDigest;
import java.security.NoSuchAlgorithmException;
import java.util.Collections;
import java.util.List;

public class StringUtil {

	public static String fristAndIndex(List<String> list) {
		Collections.sort(list);
		StringBuffer newString = new StringBuffer();
		for (int i = 0; i < list.size(); i++) {
			String bytes = list.get(i).substring(0, 1);
			newString.append(bytes);
		}
		return newString.toString();
	}

	public static String md5(String msg) throws UnsupportedEncodingException, NoSuchAlgorithmException {
		MessageDigest md = null;
		md = MessageDigest.getInstance("MD5");
		return MD5Encoder.encode(md.digest(msg.getBytes("UTF-8")));
	}

	public static boolean checkParameter(Object... parameters) {
		boolean isNull = false;
		for (int i = 0; i < parameters.length; i++) {
			Object parameter = parameters[i];
			if (parameter == null || parameter.equals("")) {
				isNull = true;
			}
		}
		return isNull;
	}
}
